﻿@using Abp.Authorization.Users
@using DevM.Web.Startup
@using DevM.Development.DataMigration.Dto
@model DevM.Web.Models.ReleaseRecord.FeedbackListViewModel
@{
    ViewBag.CurrentPageName = PageNames.ReleaseLogs; // The menu item will be active for this page.
}
@section scripts
{
    <script src="~/js/boostrap-pagination.js"></script>
    <script src="~/view-resources/Views/ReleaseRecords/Feedback.js" asp-append-version="true"></script>
}
<style>
    #create-feedback-resources .input-group {
        margin-bottom: 0px;
    }

    .resource-name {
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        margin-bottom:unset;
    }
</style>
<ol class="breadcrumb">
    <li><a href="@Url.Action("Index","Projects")">@L("Projects")</a></li>
    @if (Model.ReleaseLogId > 0)
    {
        <li><a href="@Url.Action("ReleaseLogs","ReleaseRecord")?projectId=@Model.Project.Id">@L("ReleaseLogs")</a></li>
    }
    else
    {
        <li><a href="@Url.Action("Index","ReleaseRecord")?projectId=@Model.Project.Id">@L("ReleaseRecords")</a></li>
    }
    <li class="active">@L("Feedbacks")</li>
</ol>
<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
            <div class="header">
                <h2>
                    @L("Feedbacks"):@Model.Project.Name
                </h2>
                <ul class="header-dropdown m-r--5">
                    <li class="dropdown">
                        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <i class="material-icons">more_vert</i>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><a id="RefreshButton" href="javascript:void(0);" class="waves-effect waves-block"><i class="material-icons">refresh</i>@L("Refresh")</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="body table-responsive">
                <div>
                    @foreach (var item in Model.Feedbacks.Items)
                    {
                        <div class="panel panel-default">
                            <div class="panel-heading">

                                @if (item.Status == DevM.Development.ReleaseRecords.Dto.FeedbackDto.FeedbackStatus.Pending)
                                {
                                    <i class="glyphicon glyphicon-time" style="color:#d9534f" title="@L("Pending")"></i>
                                }
                                else if (item.Status == DevM.Development.ReleaseRecords.Dto.FeedbackDto.FeedbackStatus.Claimed)
                                {
                                    <i class="glyphicon glyphicon-bookmark" style="color:#ec971f" title="@L("Claimed")"></i>
                                }
                                else if (item.Status == DevM.Development.ReleaseRecords.Dto.FeedbackDto.FeedbackStatus.Processing)
                                {
                                    <i class="glyphicon glyphicon-retweet" style="color:#337ab7" title="@L("Processing")"></i>
                                }
                                else if (item.Status == DevM.Development.ReleaseRecords.Dto.FeedbackDto.FeedbackStatus.Processed)
                                {
                                    <i class="glyphicon glyphicon-saved" style="color:#449d44" title="@L("Processed")"></i>
                                }


                                <span>@item.CreationTime</span>

                                <ul class="header-dropdown m-r--5 pull-right" style="list-style-type:none">
                                    <li class="dropdown">
                                        @if (item.Status != DevM.Development.ReleaseRecords.Dto.FeedbackDto.FeedbackStatus.Processed)
                                        {
                                            <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                                                <i class="material-icons">menu</i>
                                            </a>
                                        }

                                        <ul class="dropdown-menu pull-right">



                                            @if (item.Status == DevM.Development.ReleaseRecords.Dto.FeedbackDto.FeedbackStatus.Pending)
                                            {
                                                <li>
                                                    <a href="javascript:void(0);" class="waves-effect waves-block edit-feedback" data-feedback-id="@item.Id" data-feedback-name="" data-toggle="modal" data-target="#FeedbackEditModal">
                                                        <i class="glyphicon glyphicon-list-alt"></i>
                                                        @L("Edit")
                                                    </a>
                                                </li>
                                                <li>
                                                    <a href="javascript:void(0);" class="waves-effect waves-block delete-feedback" data-feedback-id="@item.Id" data-feedback-name="">
                                                        <i class="glyphicon glyphicon-th-list"></i>
                                                        @L("Delete")
                                                    </a>
                                                </li>
                                                <li>
                                                    <a href="javascript:void(0);" class="waves-effect waves-block delete-feedback btn-edit-feedbackstatus" data-feedback-id="@item.Id" data-feedback-status="1">
                                                        <i class="glyphicon glyphicon-bookmark"></i>
                                                        @L("SetClaimed")
                                                    </a>
                                                </li>
                                            }
                                            else if (item.Status == DevM.Development.ReleaseRecords.Dto.FeedbackDto.FeedbackStatus.Claimed)
                                            {
                                                <li>
                                                    <a href="javascript:void(0);" class="waves-effect waves-block delete-feedback btn-edit-feedbackstatus" data-feedback-id="@item.Id" data-feedback-status="2">
                                                        <i class="glyphicon glyphicon-retweet"></i>
                                                        @L("SetProcessing")
                                                    </a>
                                                </li>
                                            }
                                            else if (item.Status == DevM.Development.ReleaseRecords.Dto.FeedbackDto.FeedbackStatus.Processing)
                                            {
                                                <li>
                                                    <a href="javascript:void(0);" class="waves-effect waves-block delete-feedback btn-edit-feedbackstatus" data-feedback-id="@item.Id" data-feedback-status="3">
                                                        <i class="glyphicon glyphicon-saved"></i>
                                                        @L("SetProcessed")
                                                    </a>
                                                </li>
                                            }

                                        </ul>
                                    </li>
                                </ul>

                            </div>
                            <div class="panel-body panel-body-feedback-details" data-feedback-id="@item.Id">
                                

                                <p>@L("Path")：@item.Path</p>
                                <p>@L("Description")：@item.Description</p>
                                <p>@L("Status")：@item.Status</p>
                                <p>@L("Memo")：@item.Memo</p>

                                <p class="resource-loading"></p>
                                
                            </div>
                        </div>
                    }
                </div>
                <nav aria-label="Page navigation">
                    <ul class="pagination" data-total="@Model.Feedbacks.TotalCount">
                        <li>
                            <a href="#" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                        <li class="active"><a href="#">1</a></li>
                        <li><a href="#">2</a></li>
                        <li><a href="#">3</a></li>
                        <li><a href="#">4</a></li>
                        <li><a href="#">5</a></li>
                        <li>
                            <a href="#" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </ul>
                </nav>
                <button type="button" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-right btn-addfeedback" data-feedback-releaselogid="@Model.ReleaseLog.Id" data-toggle="modal" data-target="#FeedbackCreateModal">
                    <i class="material-icons">add</i>
                </button>

            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="FeedbackCreateModal" tabindex="-1" role="dialog" aria-labelledby="UserCreateModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span>@L("CreateNewFeedback")</span>
                </h4>
            </div>
            <div class="modal-body">
                <form name="feedbackCreateForm" role="form" novalidate class="form-validation">
                    <input type="hidden" name="ReleaseLogId" value="" />
                    <ul class="nav nav-tabs tab-nav-right" role="tablist">
                        <li role="presentation" class="active"><a href="#create-feedback-details" data-toggle="tab">@L("FeedbackDetails")</a></li>
                        <li role="presentation" class=""><a href="#create-feedback-resources" data-toggle="tab">@L("FeedbackResources")</a></li>
                    </ul>
                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane animated fadeIn active" id="create-feedback-details">

                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-12">
                                    <div class="form-group form-float">
                                        <div class="form-line">
                                            <input class="form-control" type="text" name="Path" required maxlength="200" minlength="2">
                                            <label class="form-label">@L("Path")</label>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="row clearfix">
                                <div class="col-sm-12">
                                    <div class="form-group form-float">
                                        <div class="form-line">
                                            <textarea type="text" name="Description" class="form-control" required maxlength="2000"></textarea>
                                            <label class="form-label">@L("Description")</label>
                                        </div>
                                    </div>
                                </div>
                            </div>


                            <div class="row clearfix">
                                <div class="col-sm-12">
                                    <div class="form-group form-float">
                                        <div class="form-line">
                                            <textarea type="text" name="Memo" class="form-control" maxlength="2000"></textarea>
                                            <label class="form-label">@L("Memo")</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!--resource-->


                        <div role="tabpanel" class="tab-pane animated fadeIn " id="create-feedback-resources">


                            <script type="text/template" class="add-resource-template">
                                <!--resource template-->
                                <div class="input-group">
                                    <div class="input-group">
                                        <span class="input-group-btn">
                                            <button class="btn btn-xs btn-default btn-select-resource" type="button">@L("SelectResource")</button>
                                        </span>
                                        <input type="text" class="form-control" readonly placeholder="@L("ResourceName") ...">
                                    </div><!-- /input-group -->
                                    <input type="file" style="display:none" class="form-control" name="resource">
                                    <span class="input-group-btn">
                                        <button class="btn btn-xs btn-danger btn-remove-resource" type="button">@L("Remove")</button>
                                    </span>
                                </div><!-- /input-group -->
                            </script>

                            <button class="btn btn-ms btn-primary add-resource" type="button">
                                @L("AddResource")
                            </button>
                            <br />

                            <div class="row clearfix">
                                <div class="col-sm-12">
                                    <div class="add-resource-container">
                                        <!--模板填充-->
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
                        <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="FeedbackEditModal" tabindex="-1" role="dialog" aria-labelledby="UserEditModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">

        </div>
    </div>
</div>
<!--文件模板-->
<script type="text/template" id="resource-templte">
    <ul class="list-group">
        <li class="list-group-item">
            <a href="javascript:;"><p class="resource-name"></p></a>
        </li>
    </ul>
</script>